package com.dcy.znoa.dao.attendance;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.dcy.znoa.controller.attendance.model.attUserRule.AURBindModel;
import com.dcy.znoa.controller.attendance.model.attUserRule.SelectAURBindModel;
import com.dcy.znoa.domain.Oper;
import com.dcy.znoa.domain.attendance.AttUserRule;

import java.util.List;

public interface AttUserRuleDao extends BaseMapper<AttUserRule>{

    Integer addBatch(AURBindModel model);

    Integer delBatch(AURBindModel model);

    List<Oper> selectBind(SelectAURBindModel model,Page page);

    List<Oper> selectUnBind(SelectAURBindModel model,Page page);
/**
 <update id="addBatch" parameterType="com.dcy.znoa.controller.attendance.model.attUserRule.AURBindModel" >
 INSERT INTO att_user_rule (att_rule_no,oper_id) VALUES
 <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
 (#{attRuleNo},#{item})
 </foreach>
 </update>

 <delete id="delBatch" parameterType="com.dcy.znoa.controller.attendance.model.attUserRule.AURBindModel" >
 DELETE att_user_rule  where att_rule_no = #{attRuleNo} AND  oper_id in
 <foreach collection="ids" item="item" index="index" open="(" close=")" separator=",">
 #{item}
 </foreach>
 </delete>

 <select id="selectBind" parameterType="com.dcy.znoa.controller.attendance.model.attUserRule.SelectAURBindModel" resultType="com.dcy.znoa.domain.Oper">
 SELECT so.oper_id ,so.oper_name ,so.phone_no
 FROM sys_oper so ,att_user_rule aur
 <where>
 so.oper_id = aur.oper_id
 <if test="attRuleNo!=null"><![CDATA[AND aur.att_rule_no = #{attRuleNo}]]></if>
 </where>
 </select>

 <select id="selectUnBind" parameterType="com.dcy.znoa.controller.attendance.model.attUserRule.SelectAURBindModel" resultType="com.dcy.znoa.domain.Oper">
 SELECT so.oper_id ,so.oper_name ,so.phone_no
 FROM sys_oper so ,att_user_rule aur
 left JOIN duty sd on so.duty_id = sd.duty_id
 left JOIN company c on so.comp_id = c.comp_id
 left JOIN department d on so.dep_id = d.dep_id
 <where>
 so.oper_id  not in (SELECT  oper_id
 <if test="attRuleNo!=null"><![CDATA[AND aur.att_rule_no = #{attRuleNo}]]></if>
 </where>
 </select>
 * */
}
